package com.mjh.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;
import sun.rmi.runtime.NewThreadAction;

import java.util.Properties;

/**
 * @author MJH
 * @date 2021-12-24
 * @Description Freemarker  配置
 */
@Configuration
public class FreeMarkerConfig {


    @Bean
    public FreeMarkerConfigurer freeMarkerConfigurer() {
        FreeMarkerConfigurer configurer = new FreeMarkerConfigurer();
        configurer.setTemplateLoaderPath("classpath:templates/ftl");
        Properties properties = new Properties();
        properties.setProperty("defaultEncoding", "UTF-8");
        properties.setProperty("url_escaping_charset", "utf-8");
        properties.setProperty("locale", "zh_CN");
        properties.setProperty("template_update_delay", "3600");
        properties.setProperty("tag_syntax", "auto_detect");
        properties.setProperty("whitespace_stripping", "true");
        properties.setProperty("classic_compatible", "true");
        properties.setProperty("number_format", "0.######");
        properties.setProperty("boolean_format", "true,false");
        properties.setProperty("datetime_format", "yyyy-MM-dd HH:mm:ss");
        properties.setProperty("date_format", "yyyy-MM-dd");
        properties.setProperty("time_format", "HH:mm:ss");


        configurer.setFreemarkerSettings(properties);


        return configurer;
    }


}
